package com.sky.his.api.schedule;

import com.sky.his.api.async.CheckupWorkAsync;
import com.sky.his.api.db.dao.CheckupReportDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @Author: WangJiYou
 * @Date: 2024/12/21/14:26
 * @Description:
 */
@Component
@Slf4j
public class CheckupReportSchedule {

    @Resource
    private CheckupReportDao checkupReportDao;

    @Resource
    private CheckupWorkAsync checkupWorkAsync;

    @Scheduled(cron = "0 0/1 * * * ? ")
    public void createRepost() {
        ArrayList<Integer> list = checkupReportDao.searchWillGenerateReport();
        if (list == null || list.size() == 0) {
            return;
        }
        list.forEach(one -> {
            checkupWorkAsync.createReport(one);
        });
        log.debug("对"+list.size()+"份体检报告生成报告");
    }

}
